package
{
	import events.NaviagtionEvent;
	
	import screens.InGame;
	import screens.Welcome;
	
	import starling.display.Sprite;
	import starling.events.Event;

	public class Game extends Sprite
	{
		private var screenWelcome:Welcome;
		private var screenInGame:InGame;
		
		public function Game()
		{
			super();
			this.addEventListener(starling.events.Event.ADDED_TO_STAGE, onAddedToStage);
		}
		
		private function onAddedToStage(event:Event):void
		{
			this.addEventListener(events.NaviagtionEvent.CHANGE_SCREEN, onChangeScreen);
			
			screenInGame = new InGame();
			this.addChild(screenInGame);
			screenInGame.disposeTemporarily();
			
			screenWelcome = new Welcome();
			this.addChild(screenWelcome);
			screenWelcome.initialize()
		}
		
		private function onChangeScreen(event:NaviagtionEvent):void
		{
			switch(event.params.id)
			{
				case "play":
				{
					screenWelcome.disposeTemporarily();
					screenInGame.initialize();
					break;
				}
					
				default:
				{
					break;
				}
			}
		}
	}
}